<template>
  <!-- #ifdef H5 -->
  <view v-if="visible" class="message-container" :class="[position, type]" :style="{zIndex:zIndex}">
    <text>{{ message }}</text>
  </view>
  <!-- #endif -->
</template>

<script>
export default {
  props: {
    visible: Boolean,
    message: String,
    type: {
      type: String,
      default: 'info' // success/warning/error/info
    },
    position: {
      type: String,
      default: 'center' // top/center/bottom
    },
    duration: {
      type: Number,
      default: 2000
    },
	zIndex:{
		type:Number,
		default:2000
	}
  }
}
</script>

<style scoped>
/* 所有平台通用的样式 */
.message-container {
  position: fixed;
  left: 0;
  right: 0;
  padding: 30rpx 30rpx;
  background-color: #333;
  color: #fff;
  border-radius: 0rpx;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
  max-width: 100%;
  margin: 0 auto;
  word-break: break-word;
}

.message-container.top {
  top: 0rpx;
}

.message-container.center {
  top: 50%;
  transform: translateY(-50%);
}

.message-container.bottom {
  bottom: 60rpx;
}

.message-container.success {
  background-color: #67c23a;
}

.message-container.warning {
  background-color: #e6a23c;
}

.message-container.error {
  background-color: #f56c6c;
}

.message-container.info {
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 28rpx;
}
</style>